#!/usr/bin/env bats

@test "containingSearchWords: error is thrown when search words containing one another" {
  cd $BATS_TEST_DIRNAME
  expected="Error: Search word \"passes\" contains another search word \"pass\""
  result="$(fish -c 'tbgs passes pass')"; [ "$result" = "$expected" ]
  expected="Error: Search word \"color\" contains another search word \"or\""
  result="$(fish -c 'tbgs keyword color or')"; [ "$result" = "$expected" ]
  expected="Error: Search word \"colors\" contains another search word \"color\""
  result="$(fish -c 'tbgs keyword color colors')"; [ "$result" = "$expected" ]
}

@test "containingSearchWords: error is not thrown when search words and keywords containing one another" {
  cd $BATS_TEST_DIRNAME
  expected="file11:3:In the day of grief, be mild col[01;31m[Kor[m[K
file11:5:Heart is living in tom[01;31m[Kor[m[Krow;
file11:7:In a moment, passes s[01;31m[Kor[m[Krow;
file11:9:recurring until f[01;31m[Kor[m[Kever"
  result="$(fish -c 'tbgs color or')"; [ "$result" = "$expected" ]
  expected="file11:9:recurring until forever"
  result="$(fish -c 'tbgs recurring recur')"; [ "$result" = "$expected" ]
}
